package com.cn.demo4.controller;

import com.alibaba.fastjson.JSONObject;
import com.cn.demo4.common.Tool;
import com.cn.demo4.entity.UserEntity;
import com.cn.demo4.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 注册
 * @author Administrator
 */
@Controller
public class RegisterController {
    @Autowired
    private IUserService iUserService;
    @RequestMapping("/register")
    @ResponseBody
    public void register(HttpServletResponse resp, UserEntity userEntity, HttpServletRequest req) throws IOException{
        Tool.setEncoding(req,resp);
        String result = iUserService.add(userEntity);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("result",result);
        resp.getWriter().println(jsonObject);
    }
}
